import 'package:Smart/pages/productor001/project/project_main_001.dart';
import 'package:Smart/pages/productor002/project/project_main_002.dart';
import 'package:Smart/pages/productor003/project/project_main_003.dart';
import 'package:Smart/pages/productor004/project/project_main_004.dart';
import 'package:Smart/pages/productor005/project/project_main_005.dart';
import 'package:Smart/pages/productor006/project/project_main_006.dart';
import 'package:Smart/pages/productor007/project/project_main_007.dart';
import 'package:Smart/pages/productor008/project/project_main_008.dart';
import 'package:Smart/res/colors_res.dart';
import 'package:Smart/utils/routers/page_jump_service.dart';
import 'package:flutter/material.dart';
import 'package:Smart/utils/screen_unit/gs_screen_util.dart';

class Mine extends StatefulWidget {
  @override
  _MineState createState() => _MineState();
}

class _MineState extends State<Mine> {

  List listData = [
    {"title": "1.谭文玉","num":1},
    {"title": "2.唐文煜","num":2},
    {"title": "3.张楚","num":3},
    {"title": "4.杨玉霜","num":4},
    {"title": "5.王洋钊","num":5},
    {"title": "6.字永芳","num":6},
    {"title": "7.刘佳","num":7},
    {"title": "8.杨情缘","num":8},
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        // elevation: 0,
        backgroundColor: ColorsRes.color_ffffff,
        title: Text(
          "Smart项目相关功能",
          style: TextStyle(color: ColorsRes.color_000000),
        ),
      ),
      body: GridView.count(
        //水平子Widget之间间距
        crossAxisSpacing: 10.w,
        //垂直子Widget之间间距
        mainAxisSpacing: 30.w,
        //GridView内边距
        padding: EdgeInsets.all(10.w),
        //一行的Widget数量
        crossAxisCount: 3,
        //子Widget宽高比例
        childAspectRatio: 1.0,
        children: listData.map((element) {
          return listItem(element["title"], onTap: () {
            itemAction(context, element["num"]);
          });
        }).toList()
      ),
    );
  }

  // ListItem
  Widget listItem(String title, {Function onTap}) {
    return ListTile(
      contentPadding: EdgeInsets.all(0),
      title: Container(
        // margin: EdgeInsets.all(0),
        // padding: EdgeInsets.symmetric(horizontal: 15, vertical: 10),
        child: Center(child: Text(title,style: TextStyle(fontSize: 24.w),)),
        color: Colors.purple,
      ),
      onTap: onTap,
    );
  }

  // Item事件相应
  void itemAction(BuildContext context, int index) {
    if (index == 1) {
      PageJumpService.instance().goTo(ProjectMain001());
    } else if (index == 2) {
      PageJumpService.instance().goTo(ProjectMain002());
    } else if (index == 3) {
      PageJumpService.instance().goTo(ProjectMain003());
    }else if (index == 4) {
      PageJumpService.instance().goTo(ProjectMain004());
    } else if (index == 5) {
      PageJumpService.instance().goTo(ProjectMain005());
    }else if (index == 6) {
      PageJumpService.instance().goTo(ProjectMain006());
    } else if (index == 7) {
      PageJumpService.instance().goTo(ProjectMain007());
    } else if (index == 8) {
      PageJumpService.instance().goTo(ProjectMain008());
    }
  }

}
